class Rectangle {

    // 构造函数
    constructor(width,height) {
        this.width = width;
        this.height = height;
    }

    // 属性
    color = "#ff0000"

    // 方法（行为）：写法一
    getArea() {
        return this.width * this.height;
    }

    // 方法：写法二
    getPer = function() {
        return 2 * (this.width + this.height);
    }

    // 使用箭头函数
    getMin = () => {
        return this.width < this.height ? this.width : this.height;
    }

}

const react1 = new Rectangle(100,100);
react1.width = 200;
console.log(react1.color);
console.log(react1.getArea());
console.log(react1.getMin());

// const react2 = new Rectangle(100,50);
// react2.color = "#00ff00";
// console.log(react2.color);
// console.log(react2.getArea());
